package top.jfunc.validation.spring;

import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class ParamValidateAdvisorConfig {

    @Value("${validation.aspect.pointcut}")
    private String pointcut;

    @Bean
    public AspectJExpressionPointcutAdvisor configAdvisor() {
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression(pointcut);
        advisor.setAdvice(paramValidateAdvice());
        return advisor;
    }

    @Bean
    public ParamValidateAdvice paramValidateAdvice(){
        return new ParamValidateAdvice();
    }
}